﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace HuiZe.education.Resource.Controls
{
  
    public class CusComboBox : ComboBox
    {
        TextBlock textBlock;
        TextBox textBox;
        ContentPresenter contentPresenter;
        Grid grid;
        Border Border;
        public bool IsDropDownOpen2
        {
            get { return (bool)GetValue(IsDropDownOpen2Property); }
            set { SetValue(IsDropDownOpen2Property, value); }
        }
        public static readonly DependencyProperty IsDropDownOpen2Property =
            DependencyProperty.Register("IsDropDownOpen2", typeof(bool), typeof(CusComboBox), new PropertyMetadata(null));

        public CusComboBox()
        {
            //this.AddHandler(Button.MouseDownEvent, new RoutedEventHandler(bt_MouseDown), true);
            this.MouseDown += new MouseButtonEventHandler(this.ComboBoxMouseDown);
        }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();


          

            try
            {



                //    this.Border = Template.FindName("_borderbg", this) as Border;
                //this.Border.PreviewMouseLeftButtonUp += new MouseButtonEventHandler(this.ComboBoxMouseDown);


                this.textBlock = Template.FindName("_txt2", this) as TextBlock;
                this.textBlock.PreviewMouseLeftButtonUp += new MouseButtonEventHandler(this.ComboBoxMouseDown);

                this.contentPresenter = Template.FindName("ContentSite", this) as ContentPresenter;
                this.contentPresenter.PreviewMouseLeftButtonUp += new MouseButtonEventHandler(this.ComboBoxMouseDown);

                this.grid = Template.FindName("comboxGrid", this) as Grid;
                this.grid.PreviewMouseLeftButtonUp += new MouseButtonEventHandler(this.ComboBoxMouseDown);




                this.textBox = Template.FindName("PART_EditableTextBox", this) as TextBox;
                this.textBox.PreviewMouseLeftButtonUp += new MouseButtonEventHandler(this.ComboBoxMouseDown2);
            }
            catch { }

        }


       



        public void ComboBoxMouseDown(object sender, MouseButtonEventArgs e)
        {
            IsDropDownOpen2 = true;


        }
        public void ComboBoxMouseDown2(object sender, MouseButtonEventArgs e)
        {
            IsDropDownOpen2 = true;


        }
        public void UpdateComboxStatus()
        {

            IsDropDownOpen2 = false;

        }

        public void OpenCombox()
        {

            IsDropDownOpen2 = true;

        }


        private void bt_MouseDown(object sender, RoutedEventArgs e)
        {
            //bilibili
        }
        private void MultiComboBox_Unloaded(object sender, RoutedEventArgs e)
        {
         
        }

        private void MultiComboBox_Loaded(object sender, RoutedEventArgs e)
        {
           
        }

        private void _listbox_SelectedItemChanged(object sender, RoutedEventArgs e)
        {
          
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
           
        }
    }

 
}
